Skip to content

Conversation

@alienx5499
Copy link
Contributor

Problem

The cpp-libp2p repository was failing to build on modern systems due to CMake compatibility issues with several Hunter package dependencies. These packages had outdated CMake configurations that required CMake < 3.5, but modern CMake versions have removed support for that compatibility level.

Root Cause

Multiple Hunter packages were using outdated CMake configurations:

  • Protobuf (3.19.4-p0)
  • c-ares (1.14.0-p0)
  • yaml-cpp (0.6.2-0f9a586-p1)
  • Boost.DI (1.1.0-p1)

These packages contained cmake_minimum_required(VERSION < 3.5) statements that are incompatible with modern CMake versions.

Solution

Updated the Hunter configuration in cmake/Hunter/config.cmake to add custom configurations for each problematic dependency with the CMAKE_POLICY_VERSION_MINIMUM=3.5 flag. This ensures compatibility with modern CMake versions while maintaining the existing package versions.

Changes Made

cmake/Hunter/config.cmake

  • Added custom hunter_config for Protobuf with CMake compatibility flags
  • Added custom hunter_config for c-ares with CMake compatibility flags
  • Added custom hunter_config for yaml-cpp with CMake compatibility flags
  • Added custom hunter_config for Boost.DI with CMake compatibility flags

CMakeLists.txt

  • Added CMake policy settings to handle compatibility with older dependencies
  • Set CMP0144 and CMP0000 policies for better compatibility

Testing

  • Clean build from scratch successful
  • All dependencies resolved successfully
  • Project compiles without errors
  • All test targets build successfully
  • Examples build successfully

Before/After

Before: Build failed with errors like:

CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 has been removed from CMake.

After: Build completes successfully with all targets compiled.

Impact

  • Build Success: Repository now builds successfully on modern systems
  • Developer Experience: Developers can clone and build the project without CMake errors
  • CI/CD Compatibility: Build systems with modern CMake versions will work correctly
  • No Breaking Changes: Maintains existing functionality while fixing compatibility

Related Issues

This fix addresses build failures that were preventing users from compiling the cpp-libp2p library on systems with current CMake versions.

Notes

  • No changes to the actual library code or functionality
  • Only affects the build system configuration
  • Maintains backward compatibility with existing Hunter package versions
  • Follows Hunter package manager best practices for custom configurations

@alienx5499
Copy link
Contributor Author

@turuslan Could you please review this PR when you get a chance?

@turuslan
Copy link
Contributor

turuslan commented Sep 3, 2025

Thank you for your contribution

@turuslan turuslan merged commit 8e7284c into libp2p:master Sep 3, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants